addModule({
    name: "Data Classification",

    /**
     * 本模块的初始化函数
     */
    init : function() {

        addSceneFunc("data-Classification-stage1", this.scene1_stage1, this.name, null);
        addSceneFunc("data-Classification-stage2", this.scene1_stage2, this.name, null);
        addSceneFunc("data-Classification-stage3", this.scene1_stage3, this.name, null);
    },

    graphic:{
        circle: {},
        opt: {},
    },

    scene1_stage1: function() {

        function randomX(){
            var r = Math.round(Math.random() * 20);
            return r + 5;
        }
        function randomY(){
            var r = Math.round(Math.random() * 75);
            return r + 13;
        }
        function randomDataArray(len) {
            var d = [];
            while (len--) {
                d.push([
                    randomX(),
                    randomY()
                ]);
            }
            return d;
        }
        
        var series = [{
            type:'graph',
            coordinateSystem: 'cartesian2d',
            data: randomDataArray(16),
            symbolSize:10,
            itemStyle:{
                    color:'black'
            },
            animationDelay: function (idx) {
                return idx * 10 ;
            }
        },{
            type:'graph',
            coordinateSystem: 'cartesian2d',
            data: randomDataArray(16),
            symbolSize:15,
            itemStyle:{
                    color:'purple'
            },
            animationDelay: function (idx) {
                return idx * 10 ;
            }
        },{
            type:'graph',
            coordinateSystem: 'cartesian2d',
            data: randomDataArray(16),
            symbolSize:20,
            itemStyle:{
                    color:'blue'
            },
            animationDelay: function (idx) {
                return idx * 10 ;
            }
        },{
            type:'graph',
            coordinateSystem: 'cartesian2d',
            data: randomDataArray(16),
            symbolSize:25,
            itemStyle:{
                    color:'green'
            },
            animationDelay: function (idx) {
                return idx * 10 ;
            }
        },{
            type:'graph',
            coordinateSystem: 'cartesian2d',
            data: randomDataArray(16),
            symbolSize:30,
            itemStyle:{
                    color:'brown'
            },
            animationDelay: function (idx) {
                return idx * 10 ;
            }
        },];
        //非坐标轴标点
        var option = {
            //backgroundColor: '#5d6e89',
            animationEasingUpdate: 'bounceInOut',
            tooltip:{
                trigger: 'item'
            },
            xAxis: {
                show : false,
                type : 'value',
                boundaryGap : false,
                min : 0,
                max : 100,
            },
            yAxis: {
                show : false,
                min : 0,
                max : 100,
                type : 'value'
            },
            grid: {
                top : 0,
                right : 0,
                left : 0,
                bottom : 0
            },
            series: series
        };

        myChart.setOption(option);
        this.opt = option;
        addRenderFunc(this.name + "-1", function (){
            endScene();
        }, {delay : 2000});
       
    },

    scene1_stage2 : function () {

        var circle = new echarts.graphic.Circle({
            position: [_width*0.5,_height*0.5],
            scale: [1, 1],
            shape: {
                cx: 0,
                cy: 0,
                r: 0
            },
            style: {
                fill: 'none',
                stroke: 'black',
                lineWidth: 3,
            },
             zlevel: 1009
        });


        circle.animate('shape', false).delay(100)
                .when(1000, {
                    r: _height*0.4
                }).start('cubicOut');
        this.circle = circle;

        zr.configLayer(1009, {
            motionBlur: false,
            lastFrameAlpha: 0.8,
        });

        function randomX(){
            var r = Math.round(Math.random() * 60 * _height/_width);
            return 0.91*r + 35;
        }
        function randomY(){
            var r = Math.round(Math.random() * 60);
            return 1.1*r + 22;
        }
        function randomDataArray(len) {
            var d = [];
            while (len--) {
                var x = randomX();
                var y = randomY();
                if(Math.sqrt(Math.pow(x-50,2) + Math.pow(y-50,2)) < 24){
                   d.push([
                        x,
                        y
                    ]); 
                } else{
                    len++
                }  
            }
            return d;
        }
        var option = this.opt;
        option.series[0].data = randomDataArray(16);
        option.series[1].data = randomDataArray(16);
        option.series[2].data = randomDataArray(16);
        option.series[3].data = randomDataArray(16);
        option.series[4].data = randomDataArray(16);

    
        myChart.setOption(option);
        zr.add(circle);
         addRenderFunc(this.name + "-2", function (){
            endScene();
        }, {delay : 2000});
    },

    scene1_stage3 : function () {

        var circle = this.circle;
        circle.animate('shape', false).delay(1000)
                .when(1000, {
                    r: 0
                }).start('cubicOut');
        var option = this.opt;
        option.series[1].data = [[75,90],[75,85],[75,80],[75,75],[80,90],[80,85],[80,80],[80,75],[85,90],[85,85],[85,80],[85,75],[90,90],[90,85],[90,80],[90,75]];
        option.series[2].data = [[10,90],[10,85],[10,80],[10,75],[15,90],[15,85],[15,80],[15,75],[20,90],[20,85],[20,80],[20,75],[25,90],[25,85],[25,80],[25,75]];
        option.series[3].data = [[10,10],[10,15],[10,20],[10,25],[15,10],[15,15],[15,20],[15,25],[20,10],[20,15],[20,20],[20,25],[25,10],[25,15],[25,20],[25,25]];
        option.series[4].data = [[75,10],[75,15],[75,20],[75,25],[80,10],[80,15],[80,20],[80,25],[85,10],[85,15],[85,20],[85,25],[90,10],[90,15],[90,20],[90,25]];
        myChart.setOption(option);

        addRenderFunc(this.name + "-3", function (){
             option.series[0].itemStyle.color = '#fff';
              myChart.setOption(option);
        }, {delay : 1200});

        addRenderFunc(this.name + "-4", function (){
              zr.remove(this.circle);
              myChart.clear();
              endScene();
        }, {delay : 7000});
    }

});